package com.xpu.cos.controller;


import com.xpu.cos.entity.User;
import com.xpu.cos.result.Result;
import com.xpu.cos.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ambitionjh
 * @since 2024-01-02
 */
@RestController
@RequestMapping("/cos/user")
public class UserController {
    @Autowired
    private UserService userService;

    //添加用户
    @PostMapping("add")
    public Result addUser(@RequestBody User user){
       return userService.addUser(user);
    }
    //修改用户
    @PutMapping("update")
    public Result updateUser(@RequestBody User user){
       return userService.updateUser(user);
    }
    //根据id查询用户
    @GetMapping("get/{id}")
    public Result gteUserById(@PathVariable Integer id){
        return userService.getUserById(id);
    }
    //删除用户
    @DeleteMapping("delete/{id}")
    public Result deleteUser(@PathVariable Integer id){
        return userService.deleteUser(id);
    }

}

